﻿<?php
require_once "resource_language.php";
$errors         = array();  	// array to hold validation errors
$rdata 			= array(); 		// array to pass back data
require_once 'resource_language.php';
if (isset($_REQUEST['ajaxcallid'])) {
    if ((int) $_REQUEST['ajaxcallid'] == 26) {
        $fData = $_REQUEST['fData'];
        //get variable and create query to db
        $data=getResourceLang($fData);
        $rdata['en']=$data['en']; 
        $rdata['vi']=$data['vi']; 
        $returnData = json_encode($rdata);
        echo $returnData;
            die();    
        
    }
    else if ((int) $_REQUEST['ajaxcallid'] == 28) {
        $fData = json_decode($_REQUEST['fData'],true);        
        $tempArray = array_values($fData);
        //get variable and create query to db       
        $key=$tempArray[0];
        $module=$tempArray[1];        
        $valvi=$tempArray[2];
        $valus=$tempArray[3];            
        if(getResourceLangcode($tempArray[0],"en-US")=="resEmpty")
        {           
            insertResourceLang($key,$valus,$module,"en-US");
            //echo "success insert";
            
        }        
        else 
        {
            //update data us
            updateResourceLang($key,$valus,"en-US");
            //echo "update success";
           
        }
        if(getResourceLangcode($tempArray[0],"vi-VN")=="resEmpty")
        {
            //insert data
            insertResourceLang($key,$valvi,$module,"vi-VN");                     
        }
        else
        {
            ///update
            updateResourceLang($key,$valvi,"vi-VN");   
            //echo "update success";            
            
        }
        echo $key; 
        
        die();    
        
    }
} 
else {
    echo 'invalid';
    die();
}



/*
if (isset($_REQUEST['ajaxcallid'])) {
    if ((int) $_REQUEST['ajaxcallid'] == 26) {
        $personData = json_decode($_REQUEST['fData'],true);        
        $tempArray = array_values($personData);
        $returnData = json_encode($personData);
        echo $returnData;  
        die();
    }
} else {
    echo 'invalid';
    die();
}
*/